import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
import './assets/icon/iconfont.css'
import Event from './components/Event';
import myHttp from './http';
import log from './log';
import Api from './api/api';

Vue.config.productionTip = false
Vue.prototype.$store = store;

Vue.use(ElementUI);
Vue.use(Event);
Vue.use(myHttp);
Vue.use(log);
Vue.use(Api);


router.beforeEach((to, from, next) => {
    if (store.state.userInfo || to.path === '/login' || to.path === '/register') {
        next();
    } else {
        next({path: '/login'});
    }
})

new Vue({
    router,
    store,
    render: h => h(App)
}).$mount('#app')
